<?php

namespace JLPay\Models\BaseData;

use JLPay\Models\BaseRequest;

/**
 * MCC查询请求
 */
class MccQueryRequest extends BaseRequest
{
    /**
     * API接口路径
     */
    public const API_URL = '/open/base/data/mcc/list';

    protected ?string $mccCode = null;
    protected ?string $mccDesc = null;
    protected ?string $parentMcc = null;
    protected ?string $topCode = null;
    protected ?string $freeFlag = null;
    protected ?string $smallMerchant = null;
    protected ?string $mccLevel = null;
    protected ?int $limit = null;
    protected ?int $offset = null;

    /**
     * 设置商户类别码
     *
     * @param string $mccCode
     * @return self
     */
    public function setMccCode(string $mccCode): self
    {
        $this->mccCode = $mccCode;
        return $this;
    }

    /**
     * 设置商户类别描述
     *
     * @param string $mccDesc
     * @return self
     */
    public function setMccDesc(string $mccDesc): self
    {
        $this->mccDesc = $mccDesc;
        return $this;
    }

    /**
     * 设置父代类别码
     *
     * @param string $parentMcc
     * @return self
     */
    public function setParentMcc(string $parentMcc): self
    {
        $this->parentMcc = $parentMcc;
        return $this;
    }

    /**
     * 设置一级类别码
     *
     * @param string $topCode
     * @return self
     */
    public function setTopCode(string $topCode): self
    {
        $this->topCode = $topCode;
        return $this;
    }

    /**
     * 设置免费标志：0 否 1 是
     *
     * @param string $freeFlag 免费标志，0 否 1 是
     * @return self
     */
    public function setFreeFlag(string $freeFlag): self
    {
        $this->freeFlag = $freeFlag;
        return $this;
    }

    /**
     * 设置小微商户标志：0 不可用 1 可用
     *
     * @param string $smallMerchant 小微商户标志，0 不可用 1 可用
     * @return self
     */
    public function setSmallMerchant(string $smallMerchant): self
    {
        $this->smallMerchant = $smallMerchant;
        return $this;
    }

    /**
     * 设置MCC级别
     *
     * @param string $mccLevel
     * @return self
     */
    public function setMccLevel(string $mccLevel): self
    {
        $this->mccLevel = $mccLevel;
        return $this;
    }

    /**
     * 设置每页记录数
     *
     * @param int $limit
     * @return self
     */
    public function setLimit(int $limit): self
    {
        $this->limit = $limit;
        return $this;
    }

    /**
     * 设置偏移量
     *
     * @param int $offset 偏移量，pageSize = offset / limit + 1，示例值：如果limit为10，则第二页offset传11
     * @return self
     */
    public function setOffset(int $offset): self
    {
        $this->offset = $offset;
        return $this;
    }

    /**
     * 转换为数组
     *
     * @return array
     */
    public function toArray(): array
    {
        $data = parent::toArray();
        
        if ($this->mccCode !== null) {
            $data['mcc_code'] = $this->mccCode;
        }
        if ($this->mccDesc !== null) {
            $data['mcc_desc'] = $this->mccDesc;
        }
        if ($this->parentMcc !== null) {
            $data['parent_mcc'] = $this->parentMcc;
        }
        if ($this->topCode !== null) {
            $data['top_code'] = $this->topCode;
        }
        if ($this->freeFlag !== null) {
            $data['free_flag'] = $this->freeFlag;
        }
        if ($this->smallMerchant !== null) {
            $data['small_merchant'] = $this->smallMerchant;
        }
        if ($this->mccLevel !== null) {
            $data['mcc_level'] = $this->mccLevel;
        }
        if ($this->limit !== null) {
            $data['limit'] = $this->limit;
        }
        if ($this->offset !== null) {
            $data['offset'] = $this->offset;
        }
        
        return $data;
    }
} 